
function list_carousel(){
	/*
	if($('body').width() < 459){
	  maxnum = $('.wrapper').width()+'px';
	  $('.list_carousel li').css('width',maxnum);
	}else{
	  maxnum = "100%";	
	  $('.list_carousel li').attr('style','');
	};
	*/
	
	$('#hotNews').carouFredSel({
		auto: false,
		pagination: "#sliderpager1",
		//mousewheel: true,
		responsive: true,
		width: '100%',
		height: 'auto',
		swipe: {
			onMouse: true,
			onTouch: true
		},
		auto: {
			pauseOnHover: 'resume',
			progress: '#timer1'
		}
	});
};

function info_maxheight(){
	var height = $(".screenshot img").height();
	if(height<122){
		$(".screenshot .info").css('height',height);
	}else{
		$(".screenshot .info").css('height',122);
		}
};

function opclose(obj,div){
	if($(obj).is('.od_button')){
	  $(".filter").hide('slow');
	  $(".sub_menu .tag a").attr('class','od_button');
	  $(".sub_menu .color a").attr('class','od_button');
	  $(div).show('slow');
	  $(obj).attr('class','od_button_open');
	}else {
      $(".filter").hide('slow');
	  $(".sub_menu .tag a").attr('class','od_button');
	  $(".sub_menu .color a").attr('class','od_button');
      $(div).hide('slow');
	  $(obj).attr('class','od_button');
    }	
};

function DivSwitch(obj){
    if($(obj).is('.a_l_open')){
        $(obj).siblings('.dictc_m').slideUp();
		$(obj).attr('class','a_l');
        $('em',obj).attr('class','icon-folder-close');
    } else {
        $(obj).siblings('.dictc_m').slideDown();
		$(obj).attr('class','a_l_open');
        $('em',obj).attr('class','icon-folder-open');
    }
}

function addcss(obj){
	$(".allpic_ser .pic").attr('class','pic');
	$(".allpic_ser .pic").addClass(obj);
}

$(function(){
	$('header .menu_icon').click(function(){
		$('header .menu').css('display','inline-block');
	  	$('header .menu').stop().animate({width:'220px'},{queue:false,duration:400});
		setTimeout(function(){$('header .menu_close').css('display','inline-block');},400);
	});
	$('header .menu_close').click(function(){
		$('header .menu').stop().animate({width:'0px'},{queue:false,duration:400});
		$('header .menu_close').css('display','none');
		$('header .menu').css('display','none');
	});
	
	/*幻灯片首页*/
	list_carousel();
	$("#tabs").tabs();
	//
	$('.listitem li').hover(function(){
      $(".info", this).animate({opacity:'1'},{queue:false,duration:300});
      }, function() {
	  $(".info", this).stop().animate({opacity:'0'},{queue:false,duration:300});
    });
	//
	info_maxheight();
	//
	$('.with_image').hover(function(){
		$(".image_container", this).stop().show();
	}, function() {
		$(".image_container", this).stop().hide();
	});
	//Side Bar Scroller
	if($(".centre_col_list").length > 0)
	{
		   var $sidebar   = $(".centre_col_list"),
			$window    = $(window),
			offset     = $sidebar.offset(),
			topPadding = 10;
			bot_limit = $('body').height()-810;
	
		$window.scroll(function() {
			if ($window.scrollTop() > offset.top && $window.scrollTop() < bot_limit ) {
			//if ($window.scrollTop() > offset.top || offset.top < $('#post-content').height() + 150) {
				$sidebar.stop().animate({
					marginTop: $window.scrollTop() - offset.top + topPadding
				});
			} else {
				
				if ($window.scrollTop() < offset.top){
					$sidebar.stop().animate({ marginTop: 0 });
				}
			}
	   });
	}
	//
	

});


$(window).resize(function(){
	if($('body').width() > 750){
		setTimeout(function(){$('header .menu').attr('style','');$('header .menu_close').attr('style','');},500);
	}
	/*
	if($('body').width() < 459){
	  maxnumi = ($('.wrapper').width()+'px');
	  $('.list_carousel li').css('width',maxnumi);
	  list_carousel(maxnum);
	}
	*/
	setTimeout("list_carousel();",500)
	//
	info_maxheight();
});